<template>
  <div>
    <Navbar :title = "title" />
  <iframe ref="iframe" scrolling="auto" width="100%" height="100%" frameborder="0"></iframe>
  </div>
</template>

<script>
export default {
  name: "news.detail",
  props: ['title'],
  data() {
    return {
      detail: ""
    };
  },
  created() {
    let id = this.$route.query.id;
    console.log(id);
    this.$axios.get(`getnew?id=${id}`)
      .then(res => {
        console.log(res);
        this.detail = res.data;
        // console.log(this.detail.htmlSrc);
        this.$refs.iframe.contentWindow.location.replace(this.detail.htmlSrc);
      })
      .catch(err => {
        console.log("加载子新闻详情失败", err);
      });
  }
};
</script>


/* // 这里的 scoped 表示只在当前组件起作用 （局部） */
<style lang="css" scoped>
* {
  margin: 0;
  padding: 0;
}
iframe {
  position: absolute;
  top: 41px;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  margin: 0;
  margin-bottom: 55px;
  padding: 0;
  border: 0;
}
</style>